﻿using AiShou.BLL;
using AiShou.Common.Vod;
using AiShou.IBLL;
using AiShou.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AiShou.WebSite
{
    /// <summary>
    /// 视频播放页
    /// </summary>
    public partial class Play : Page
    {
        public string VideoId;
        public int UserId;
        public TBVideos Video;
        public TBUsers Author;
        public GetPlayInfoResult playInfo;
        public bool IsLike;
        public long LikeCount;
        public long DiscussCount;

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.VideoId = Request.QueryString["id"];
                TBUsers user = IdentityManager.ReadUser();
                this.UserId = user.Id;
                // 获取发布者信息
                IVideoManager videoManager = new VideoManager();
                this.Video = videoManager.GetVideoByVideoId(this.VideoId).ReadResult();
                this.Author = Video.TBUsers;
                // 获取播放地址
                this.playInfo = videoManager.InitPlay(this.VideoId).ReadResult();
                //// 点赞
                ILikeManager likeManager = new LikeManager();
                this.IsLike = likeManager.IsLike(VideoId, UserId);
                this.LikeCount = likeManager.Count(VideoId);
                //// 评论
                IDiscussManager discussManager = new DiscussManager();
                this.DiscussCount = discussManager.Count(VideoId);
            }
        }
    }
}